//===============================================================================
// Microsoft patterns & practices
// Web Client Software Factory
//===============================================================================
// Copyright  Microsoft Corporation.  All rights reserved.
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
// LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
// FITNESS FOR A PARTICULAR PURPOSE.
//===============================================================================
// The example companies, organizations, products, domain names,
// e-mail addresses, logos, people, places, and events depicted
// herein are fictitious.  No association with any real company,
// organization, product, domain name, email address, logo, person,
// places, or events is intended or should be inferred.
//===============================================================================

using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using Microsoft.Practices.ObjectBuilder;
using Microsoft.Practices.CompositeWeb;
using Metro.Admin.BusinessEntities;
using Metro.Admin.DataAccess;
using Metro.Admin.Services;   

namespace Metro.Admin.Views
{
    public class DefaultViewPresenter : Presenter<IDefaultView>
    {
        private IAdminService _adminService;

        public DefaultViewPresenter([ServiceDependency] IAdminService adminService)
        {
            _adminService = adminService;
        }

        public override void OnViewLoaded()
        {
            List<Customer> customers = null;
            customers = _adminService.GetCustomers();
            View.ShowCustomers(customers);

            ICollection<City> cities = null;
            cities = _adminService.GetCities();
            View.ShowCities(cities);

            List<User> users = null;
            users = _adminService.GetUsers();
            View.ShowUsers(users);
        }

        public IList<Customer> ShowCustomers()
        {
            List<Customer> customers = null;
            customers = _adminService.GetCustomers();
            return customers; 
        }

        public void UpdateCustomer(Customer customer)
        {
            _adminService.UpdateCustomer(customer);  
        }

        public void CreateCustomer(Customer customer)
        {
            _adminService.CreateCustomer(customer);  
        }

        public void DeleteCustomer(Customer customer)
        {
            _adminService.DeleteCustomer(customer);  
        }

        //public List<Customer> GetCustomers()
        //{
        //    List<Customer> customers = null;
        //    customers = _adminService.GetCustomers();
        //    return customers;
        //}

        public void UpdateUser(User user)
        {
            _adminService.UpdateUser(user);
        }

        public void CreateUser(User user)
        {
            _adminService.CreateUser(user);
        }

        public void DeleteUser(User user)
        {
            _adminService.DeleteUser(user);
        }
    }
}
